The DateValue and Date functions are equivalent to CDate. However, Date can only be used in Crystal syntax since it is a type name in Basic syntax.
CDate (number) converts and returns a Date given a number which is the number of days starting from December 30, 1899.
CDate (string) converts and returns a Date given a string.
CDate (dateTime) converts and returns a Date given a DateTime value.
CDate (YYYY, MM, DD) uses the given arguments to create a Date value.
The following examples are applicable to both Basic and Crystal syntax:
Returns the Date value for Dec. 31, 1999.
Returns the Date value for February 18, 1900.
CDate (#Oct. 20, 1999 12:02pm#)
Returns the Date value for October 20, 1999.
Returns the Date value for July 30, 1930.
You can use the IsDate function to check if a String argument can be converted to a Date before doing the actual conversion. That way, if the conversion cannot be done, you can handle the situation appropriately.
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |